import { constantRoutes } from '@/router'

const state = {
  menuList: '', // 菜单key值对象
  showFlg: ''
}

const mutations = {
  CHANGE_MENU_LIST: (state, obj) => {
    state.menuList = obj
  },
  CHANGE_URL: (state, obj) => {
    state.showFlg = obj
    constantRoutes[5].redirect = obj
  }
}

const getters = {
  changeMenu(state) {
    return state.menuList
  },
  changeUrl() {
    return state.showFlg
  }
}

const actions = {
  changeList({ commit }, obj) {
    commit('CHANGE_MENU_LIST', obj)
    // console.log(obj)
  },
  changeUrl({ commit }, obj) {
    commit('CHANGE_URL', obj)
    console.log(obj)
  }
}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
